package Day2025_04_17;

import java.util.Arrays;
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m = in.nextInt(), n = in.nextInt();
        int[] nums = new int[m + n];
        int[] hash = new int[100001];
        int tmp = 0;
        for (int i = 0; i < m + n; i++) {
            nums[i] = Integer.MAX_VALUE;
            int x = in.nextInt();
            if (hash[x] == 0) {
                tmp++;
                nums[i] = x;
            }
            hash[x]++;
        }
        Arrays.sort(nums);
        for (int i = 0; i < tmp; i++) {
            if (i == m + n - 1) System.out.print(nums[i]);
            else System.out.print(nums[i] + " ");
        }
    }
}
